package bootstrap

import (
	"github.com/kataras/golog"
	"sdn-executor/config"
	"sdn-executor/storage/sql"
	"sdn-executor/storage/sql/executor"
)

// InitExecutorDB 初始化执行器数据库客户端
func InitExecutorDB(conf *config.SQLDBConfig) error {
	db, err := sql.NewSQLDB(conf, conf.Dsn)
	if err == nil {
		executor.ExeDB = db
		golog.Infof("success to init lilou drds client, dsn1:%s", conf.Dsn)
	} else {
		golog.Errorf("failed to init lilou drds client, dsn1:%s, err:%+v", conf.Dsn, err)
		return err
	}

	return nil
}
